package com.shark.demo;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName CallableDemo
 * @Description TODO
 * @Author 东北彭于晏
 * @Date 2024/9/30  9:59
 * @Version 1.0
 **/
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        MyThread m = new MyThread();

        FutureTask<Integer> futureTask = new FutureTask(new MyThread());

        new Thread(futureTask, "a").start();
        System.out.println(futureTask.get());
    }
}

class MyThread implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return 111;
    }
}